From ea1e1b2e79eba561c5386ac1cf87cd55f9bc1364 Mon Sep 17 00:00:00 2001 From: robertl Date: Sat, 25 Mar 2006 04:54:35 +0000 Subject: [PATCH] etasse contributes reader for Aspecto Software WiFiFoFum 2.0 for Pocket PC. --- gpsbabel/Makefile | 2 +- gpsbabel/readme.xml | 8 + gpsbabel/reference/wfff.gpu | 1 + gpsbabel/reference/wfff.xml | 17 +++ gpsbabel/vecs.c | 7 + gpsbabel/wfff_xml.c | 295 ++++++++++++++++++++++++++++++++++++ 6 files changed, 329 insertions(+), 1 deletion(-) create mode 100644 gpsbabel/reference/wfff.gpu create mode 100644 gpsbabel/reference/wfff.xml create mode 100644 gpsbabel/wfff_xml.c diff --git a/gpsbabel/Makefile b/gpsbabel/Makefile index f5a79dd13..40777c9bc 100644 --- a/gpsbabel/Makefile +++ b/gpsbabel/Makefile @@ -47,7 +47,7 @@ FMTS=magproto.o gpx.o geo.o mapsend.o mapsource.o garmin_tables.o \ vcf.o overlay.o kml.o google.o lowranceusr.o an1.o tomtom.o \ tef_xml.o maggeo.o pathaway.o vitosmt.o gdb.o bcr.o coto.o \ ignrando.o stmwpp.o msroute.o cst.o nmn4.o mag_pdb.o compegps.o \ - yahoo.o unicsv.o + yahoo.o unicsv.o wfff_xml.o FILTERS=position.o duplicate.o arcdist.o polygon.o smplrout.o \ reverse_route.o sort.o stackfilter.o trackfilter.o discard.o \ diff --git a/gpsbabel/readme.xml b/gpsbabel/readme.xml index 7994b74d9..4cbb969cd 100644 --- a/gpsbabel/readme.xml +++ b/gpsbabel/readme.xml @@ -1620,6 +1620,14 @@ Position data is written in the notes field. Support for writing .SMT tracks is very experimental and may crash VitoNavigator II on the Pocket PC. +
+ + Aspecto Software's WiFiFoFum + + WFFF is the export format for Aspecto Software's WiFiFoFum 2.0 for Windows Mobile PCs. + It is a simple XML format that is read-only to GPSBabel and stores information about a WiFi stumbling session. + All WiFi-specific elements are written in the description field, similar to the netstumbler format. +
For user supplied style files diff --git a/gpsbabel/reference/wfff.gpu b/gpsbabel/reference/wfff.gpu new file mode 100644 index 000000000..dec2b1836 --- /dev/null +++ b/gpsbabel/reference/wfff.gpu @@ -0,0 +1 @@ +WitoldM 4529.388N 07541.190W 0000000m 001217AD3124/AP/WEP On/Ch 11/- a diff --git a/gpsbabel/reference/wfff.xml b/gpsbabel/reference/wfff.xml new file mode 100644 index 000000000..fc70b56d2 --- /dev/null +++ b/gpsbabel/reference/wfff.xml @@ -0,0 +1,17 @@ + + + On + 001217AD3124 + WitoldM + AP + 0 + -77 + -85 + 11 + 2006-03-11T09:07:46-05:00 + 2006-03-11T09:07:52-05:00 + 14.2 + 45.489801666666672 + -75.686505 + + diff --git a/gpsbabel/vecs.c b/gpsbabel/vecs.c index f85623694..22343318f 100644 --- a/gpsbabel/vecs.c +++ b/gpsbabel/vecs.c @@ -95,6 +95,7 @@ extern ff_vecs_t tpo_vecs; extern ff_vecs_t unicsv_vecs; extern ff_vecs_t vcf_vecs; extern ff_vecs_t vitosmt_vecs; +extern ff_vecs_t wfff_xml_vecs; extern ff_vecs_t xcsv_vecs; extern ff_vecs_t yahoo_vecs; @@ -425,6 +426,12 @@ vecs_t vec_list[] = { "Vito Navigator II tracks", "smt" }, + { + &wfff_xml_vecs, + "wfff", + "WiFiFoFum 2.0 for PocketPC XML", + "xml" + }, { &gdb_vecs, "gdb", diff --git a/gpsbabel/wfff_xml.c b/gpsbabel/wfff_xml.c new file mode 100644 index 000000000..c9cc2d441 --- /dev/null +++ b/gpsbabel/wfff_xml.c @@ -0,0 +1,295 @@ +/* + Copyright (C) 2006 Etienne Tasse etasse@yahoo.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA + + */ +#include "defs.h" +#include "xmlgeneric.h" + +/* argument storage */ +static char * aicicon =0; +static char * aioicon =0; +static char * ahcicon =0; +static char * ahoicon =0; +static char * snmac =0; + +static +arglist_t wfff_xml_args[] = { + {"aicicon", &aicicon, "Infrastructure closed icon name", + "Red Square", ARGTYPE_STRING }, + {"aioicon", &aioicon, "Infrastructure open icon name", + "Green Square", ARGTYPE_STRING }, + {"ahcicon", &ahcicon, "Ad-hoc closed icon name", + "Red Diamond", ARGTYPE_STRING }, + {"ahoicon", &ahoicon, "Ad-hoc open icon name", + "Green Diamond", ARGTYPE_STRING }, + {"snmac", &snmac, "Shortname is MAC address", NULL, ARGTYPE_BOOL }, + {0, 0, 0, 0, 0} +}; + +#define xfreez(p) { if (p) xfree(p); p=0; } + +#define MYNAME "wfff_xml" +#define MY_CBUF 4096 + +#if NO_EXPAT +void +wfff_xml_rd_init(const char *fname) +{ + fatal(MYNAME ": This build excluded WFFF_XML support because expat was not installed.\n"); +} +void +wfff_xml_read(void) +{ +} +void +wfff_xml_rd_deinit(void) +{ +} + +#else + +static xg_callback wfff_s, wfff_e; +static xg_callback wfff_wep, wfff_mac, wfff_type; +static xg_callback wfff_ssid, wfff_chan; +static xg_callback wfff_mnrssi, wfff_mxrssi; +static xg_callback wfff_first, wfff_last; +static xg_callback wfff_hdop, wfff_lat, wfff_lon; + +static +xg_tag_mapping loc_map[] = { + { wfff_s, cb_start, "/DocumentElement/AP" }, + { wfff_e, cb_end, "/DocumentElement/AP" }, + { wfff_wep, cb_cdata, "/DocumentElement/AP/WEP" }, + { wfff_mac, cb_cdata, "/DocumentElement/AP/MAC" }, + { wfff_ssid, cb_cdata, "/DocumentElement/AP/SSID" }, + { wfff_type, cb_cdata, "/DocumentElement/AP/Type" }, + { wfff_mnrssi, cb_cdata, "/DocumentElement/AP/MinRSSI" }, + { wfff_mxrssi, cb_cdata, "/DocumentElement/AP/MaxRSSI" }, + { wfff_chan, cb_cdata, "/DocumentElement/AP/Channel" }, + { wfff_first, cb_cdata, "/DocumentElement/AP/FirstSeen" }, + { wfff_last, cb_cdata, "/DocumentElement/AP/LastSeen" }, + { wfff_hdop, cb_cdata, "/DocumentElement/AP/HDOP" }, + { wfff_lat, cb_cdata, "/DocumentElement/AP/Lat" }, + { wfff_lon, cb_cdata, "/DocumentElement/AP/Lon" }, + { 0,0,0 } +}; + +/* work variables for wfff_xxx */ +static char* ap_mac =0; +static char* ap_ssid =0; +static char* ap_type =0; +static char* ap_wep =0; +static int ap_chan =0; +static time_t ap_first =0; +static char* ap_last =0; +static float ap_mnrssi =0.0; +static float ap_mxrssi =0.0; +static float ap_hdop =0.0; +static double ap_lat =0.0; +static double ap_lon =0.0; + +/* Start of AP block */ +void wfff_s(const char *args, const char **unused) +{ + xfreez(ap_mac); + xfreez(ap_ssid); + xfreez(ap_type); + xfreez(ap_wep); + xfreez(ap_last); + ap_mnrssi=0.0; + ap_mxrssi=0.0; + ap_chan=0; + ap_hdop=0.0; + ap_first=0; + ap_last=0; + ap_lat=0.0; + ap_lon=0.0; +} + +void wfff_mac(const char *args, const char **unused) +{ + if (args) ap_mac = xstrdup(args); +} + +void wfff_ssid(const char *args, const char **unused) +{ + if (args) ap_ssid = xstrdup(args); +} + +void wfff_type(const char *args, const char **unused) +{ + if (args) ap_type = xstrdup(args); +} + +void wfff_mnrssi(const char *args, const char **unused) +{ + if (args) ap_mnrssi = atof(args); +} + +void wfff_mxrssi(const char *args, const char **unused) +{ + if (args) ap_mxrssi = atof(args); +} + +void wfff_chan(const char *args, const char **unused) +{ + if (args) ap_chan = atoi(args); +} + +void wfff_first(const char *args, const char **unused) +{ + if (args) { + ap_first = xml_parse_time(args); + } +} + +void wfff_last(const char *args, const char **unused) +{ + if (args) ap_last = xstrdup(args); +} + +void wfff_wep(const char *args, const char **unused) +{ + if (args) ap_wep = xstrdup(args); +} + +void wfff_hdop(const char *args, const char **unused) +{ + if (args) ap_hdop = atof(args); +} + +void wfff_lat(const char *args, const char **unused) +{ + if (args) ap_lat = atof(args); +} + +void wfff_lon(const char *args, const char **unused) +{ + if (args) ap_lon = atof(args); +} + +/* End of AP Block, set waypoint and add */ +static long tosscount=0; + +void wfff_e(const char *args, const char **unused) +{ + waypoint* wpt_tmp =0; + char desc[255] ="\0"; + + if ((ap_hdop>=1)&&(ap_hdop<50)) // Discard invalid GPS fix + { + wpt_tmp = xcalloc(sizeof(*wpt_tmp), 1); + + if ( snmac ) { + wpt_tmp->shortname = xstrdup(ap_mac); + } else { + wpt_tmp->shortname = xstrdup(ap_ssid); + } + + snprintf(desc, sizeof desc, + "%s/%s/WEP %s/Ch %d/%2.0fdB/%2.0fdB/%s", + (snmac?ap_ssid:ap_mac), ap_type, ap_wep, + ap_chan, ap_mnrssi, ap_mxrssi, ap_last); + wpt_tmp->description = xstrdup(desc); + + wpt_tmp->latitude = ap_lat; + wpt_tmp->longitude = ap_lon; + wpt_tmp->hdop = ap_hdop; + wpt_tmp->altitude = unknown_alt; + wpt_tmp->fix = fix_unknown; + + wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1; + if (strncasecmp(ap_wep,"On",2)==0) { + if (strncasecmp(ap_type,"AP",2)==0) { + wpt_tmp->icon_descr = xstrdup(aicicon); /* Infra Closed */ + } else { + wpt_tmp->icon_descr = xstrdup(ahcicon); /* AdHoc Closed */ + } + } else { + if (strncasecmp(ap_type,"AP",2)==0) { + wpt_tmp->icon_descr = xstrdup(aioicon); /* Infra Open */ + } else { + wpt_tmp->icon_descr = xstrdup(ahoicon); /* AdHoc Open */ + } + } + + wpt_tmp->creation_time = ap_first; + + waypt_add(wpt_tmp); + + } else { + tosscount++; + } + + /* cleanup */ + xfreez(ap_mac); + xfreez(ap_ssid); + xfreez(ap_type); + xfreez(ap_wep); + xfreez(ap_last); + +} + + +void +wfff_xml_rd_init(const char *fname) +{ + tosscount = 0; + + xml_init(fname, loc_map, NULL); +} + +void +wfff_xml_read(void) +{ + xml_read(); +} + +void +wfff_xml_rd_deinit(void) +{ + + /* cleanup */ + xfreez(ap_mac); + xfreez(ap_ssid); + xfreez(ap_type); + xfreez(ap_wep); + xfreez(ap_last); + + xml_deinit(); + + if (tosscount) { + warning("Warning: %s reading file. Threw away %d invalid entries.\n", + MYNAME, tosscount ); + } + +} + +#endif + +ff_vecs_t wfff_xml_vecs = { + ff_type_file, + {ff_cap_read, ff_cap_none, ff_cap_none}, + wfff_xml_rd_init, + 0, + wfff_xml_rd_deinit, + 0, + wfff_xml_read, + 0, + 0, + wfff_xml_args +}; -- 2.30.2